package com.zhou.org.dto;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.zhou.org.common.AttachmentUtil;
import com.zhou.org.dao.User;
import com.zhou.org.model.OrgTree;
import lombok.Data;
import org.springframework.beans.BeanUtils;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * <p>
 * 
 * </p>
 *
 * @author lang.zhou
 * @since 2022-08-23
 */
@Data
public class UserInfoDto implements Serializable {

    private static final long serialVersionUID=1L;

    /**
     * 用户id
     */
    private Integer userId;

    /**
     * 用户名
     */
    private String username;

    /**
     * 姓名
     */
    private String realName;

    /**
     * 性别
     */
    private Integer sex;
    /**
     * 邮箱
     */
    private String email;
    /**
     * 电话
     */
    private String phone;

    private String description;

    /**
     * 创建日期
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createDt;

    /**
     * 微信code
     */
    private String wxCode;

    /**
     * 头像
     */
    private String avatar;

    /**
     * 行政上级
     */
    private String superiorName;

    /**
     * 是否锁定
     */
    private Integer locked;
    private Integer orgId;

    private List<OrgTree> parent;

    public UserInfoDto(User user) {
        BeanUtils.copyProperties(user, this);
        String avatar = AttachmentUtil.getAvatar(user.getRelativeAvatar());
        setAvatar(avatar);
    }
}
